SituationB <- function(pval){
  #The goal of this function is to replicate Situation B from Simmons et al. (2011)  
  #Generation of the first 20 observations
  Sample1 <- rnorm(20, 0, 1) #Generate normal random variables with mean = 0 and var = 1
  
  #First t-test
  t.test1 <- t.test(Sample1)
  
  #Now we collect 10 additional observations
  Sample1bis <- rnorm(10, 0, 1) #Generate normal random variables with mean = 0 and var = 1
  Sample1.full <- c(Sample1,Sample1bis) #Full sample with 30 observations
  
  #Second t-test
  t.test2 <- t.test(Sample1.full)
  
  #signif = 1 if at least one test gives p < pval, O otherwise
  signif <- ifelse(t.test1$p.value < pval | 
                     t.test2$p.value < pval,
                   1, 0)
  return(signif) #value returned by the function
}

